package cn.qiao.mdc.jdk;

import cn.qiao.mdc.util.Util;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MDCInterceptor implements InvocationHandler {

    private final Object target;

    public MDCInterceptor(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return Util.trace(() -> method.invoke(target, args));
    }
}
